package com.education.wisdom.service.impl;

import com.education.common.utils.Convert;
import com.education.wisdom.mapper.JrReportformMapper;
import com.education.wisdom.pojo.Catalog;
import com.education.wisdom.pojo.JrReportform;
import com.education.wisdom.pojo.dto.JrReportformDTO;
import com.education.wisdom.service.IJrReportformService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 举报 服务层实现
 *
 * @author d
 * @date 2020-07-11
 */
@Service
public class JrReportformServiceImpl implements IJrReportformService {

    @Autowired
    private JrReportformMapper jrReportformMapper;

    /**
     * 查询举报信息
     *
     * @param id 举报ID
     * @return 举报信息
     */
    @Override
    public JrReportform selectJrReportformById(Integer id) {
        return jrReportformMapper.selectJrReportformById(id);
    }

    /**
     * 查询举报列表
     *
     * @param jrReportform 举报信息
     * @return 举报集合
     */
    @Override
    public List<JrReportform> selectJrReportformList(JrReportform jrReportform) {
        return jrReportformMapper.selectJrReportformList(jrReportform);
    }

    /**
     * 新增举报
     *
     * @param jrReportform 举报信息
     * @return 结果
     */
    @Override
    public int insertJrReportform(JrReportform jrReportform) {
        return jrReportformMapper.insertJrReportform(jrReportform);
    }

    /**
     * 删除举报信息
     *
     * @param id 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteJrReportformById(Integer id) {
        return jrReportformMapper.deleteJrReportformById(id);
    }

    /**
     * 修改举报
     *
     * @param jrReportform 举报信息
     * @return 结果
     */
    @Override
    public int updateJrReportform(JrReportform jrReportform) {
        return jrReportformMapper.updateJrReportform(jrReportform);
    }

    /**
     * 删除举报对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteJrReportformByIds(String ids) {
        return jrReportformMapper.deleteJrReportformByIds(Convert.toStrArray(ids));
    }

    @Override
    public PageInfo<JrReportformDTO> pageList(JrReportformDTO jrReportform) {
        Integer pageSize = jrReportform.getPageSize();
        Integer pageNum = jrReportform.getPageNum();
        if (pageNum!= null && pageSize != null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<JrReportformDTO> list = jrReportformMapper.pageList(jrReportform);
        PageInfo<JrReportformDTO> info = new PageInfo<>(list);
        return info;
    }
}